<script setup lang="ts">
import { ref } from 'vue'

const departments = [
    { id: 1, name: '内科', doctors: ['张医生', '王医生', '李医生'] },
    { id: 2, name: '外科', doctors: ['刘医生', '陈医生', '周医生'] },
    { id: 3, name: '骨科', doctors: ['吴医生', '郑医生', '孙医生'] },
    { id: 4, name: '眼科', doctors: ['林医生', '杨医生', '赵医生'] }
]

const selectedDepartment = ref('')
const selectedDoctor = ref('')
const selectedDate = ref('')
const selectedPeriod = ref('')

const availableDates = [
    '2024-03-20',
    '2024-03-21',
    '2024-03-22',
    '2024-03-23',
    '2024-03-24'
]

const periods = [
    '上午 8:00-10:00',
    '上午 10:00-12:00',
    '下午 14:00-16:00',
    '下午 16:00-18:00'
]

const getDoctors = () => {
    const dept = departments.find(d => d.name === selectedDepartment.value)
    return dept ? dept.doctors : []
}
</script>

<template>
    <div class="register-page">
        <h2 class="page-title">预约挂号</h2>

        <div class="register-form">
            <!-- 科室选择 -->
            <div class="form-group">
                <label class="form-label">选择科室：</label>
                <select v-model="selectedDepartment" class="form-select">
                    <option value="">请选择科室</option>
                    <option v-for="dept in departments" :key="dept.id" :value="dept.name">
                        {{ dept.name }}
                    </option>
                </select>
            </div>

            <!-- 医生选择 -->
            <div class="form-group">
                <label class="form-label">选择医生：</label>
                <select v-model="selectedDoctor" class="form-select" :disabled="!selectedDepartment">
                    <option value="">请选择医生</option>
                    <option v-for="doctor in getDoctors()" :key="doctor" :value="doctor">
                        {{ doctor }}
                    </option>
                </select>
            </div>

            <!-- 日期选择 -->
            <div class="form-group">
                <label class="form-label">选择日期：</label>
                <select v-model="selectedDate" class="form-select" :disabled="!selectedDoctor">
                    <option value="">请选择日期</option>
                    <option v-for="date in availableDates" :key="date" :value="date">
                        {{ date }}
                    </option>
                </select>
            </div>

            <!-- 时段选择 -->
            <div class="form-group">
                <label class="form-label">选择时段：</label>
                <select v-model="selectedPeriod" class="form-select" :disabled="!selectedDate">
                    <option value="">请选择时段</option>
                    <option v-for="period in periods" :key="period" :value="period">
                        {{ period }}
                    </option>
                </select>
            </div>

            <!-- 提交按钮 -->
            <button class="submit-button" :disabled="!selectedPeriod">
                确认预约
            </button>

            <!-- 帮助提示 -->
            <div class="help-tips">
                <p>需要帮助？</p>
                <p>请拨打咨询电话：0123-4567890</p>
            </div>
        </div>
    </div>
</template>

<style scoped>
.register-page {
    padding: 20px;
    background-color: #f5f5f5;
}

.page-title {
    font-size: 24px;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 30px;
}

.register-form {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.form-group {
    margin-bottom: 25px;
}

.form-label {
    display: block;
    font-size: 18px;
    margin-bottom: 10px;
    color: #333;
}

.form-select {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background-color: white;
}

.form-select:disabled {
    background-color: #f5f5f5;
}

.submit-button {
    width: 100%;
    padding: 15px;
    font-size: 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    margin-top: 20px;
}

.submit-button:disabled {
    background-color: #cccccc;
}

.help-tips {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f8f8;
    border-radius: 8px;
    text-align: center;
}

.help-tips p {
    margin: 5px 0;
    color: #666;
}
</style> 